package edu.xlh.travel.controller.admin;

import com.alibaba.fastjson.JSONArray;
import edu.xlh.travel.common.Result;
import edu.xlh.travel.pojo.ScoreDetail;
import edu.xlh.travel.pojo.SysLog;
import edu.xlh.travel.pojo.querypojo.QueryCheckTask;
import edu.xlh.travel.pojo.querypojo.QueryScoreDetail;
import edu.xlh.travel.service.ScoreDetailService;
import edu.xlh.travel.syslog.annontion.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.HashMap;

@Controller
@RequestMapping("/scoreDetail")
public class ScoreDetailController {

    @Autowired
    private ScoreDetailService scoreDetailService;

    /*
     * to sysLogInfoList page
     * */
    @Log("跳转积分详情列表")
    @RequestMapping("/scoreDetailList")
    public String scoreDetailList(String userId , Model model) {
        model.addAttribute("userId" , userId);
        return "admin/scoremanage/scoreDetailList";
    }

  /*  *//*
     * find scoreDetail by userId
     * *//*
    @RequestMapping("/findScoreDetailByUserId")
    @ResponseBody
    public Result findScoreDetailByUserId(@RequestBody ScoreDetail scoreDetail , HttpSession session) {
        return scoreDetailService.findScoreDetailByUserId(scoreDetail , session);
    }*/
    @Log("查询时所有的积分详情")
    @RequestMapping("/findAllScoreDetail")
    @ResponseBody
    public Result findAllScoreDetail(int page, int limit , String userId , HttpSession session) {
        return scoreDetailService.findAllScoreDetail(page , limit , userId , session);
    }

    @Log("根据用户id查询积分详情")
    @RequestMapping("/findScoreDetailByUserId/{userId}")
    @ResponseBody
    public Result findScoreDetailByUserId(int page  , int limit , @PathVariable("userId") String userId, HttpSession session) {
        return scoreDetailService.findScoreDetailByUserId(page , limit , userId, session);
    }

    /*
     *
     * batch delete
     *  */
    @Log("批量删除积分详情")
    @RequestMapping("/batchDelete")
    @ResponseBody
    public Result batchDelete(@RequestBody JSONArray jsonArray , HttpSession session) {
        return scoreDetailService.batchDelete(jsonArray , session);
    }

    /*
     * delete scoreDetail by id
     * */
    @Log("根据id删除积分详情")
    @RequestMapping("/deleteById/{id}")
    @ResponseBody
    public Result deleteById(@PathVariable("id") String id , @RequestBody HashMap hashMap , HttpSession session) {
        return scoreDetailService.deleteById(id , hashMap , session);
    }

    /*
     * query scoreDetail by condition
     * */
    @Log("条件模糊查询积分详情")
    @RequestMapping("/QueryScoreDetailByCondition")
    @ResponseBody
    public Result  QueryScoreDetailByCondition(Integer page, Integer limit,  QueryScoreDetail queryScoreDetail , HttpSession session) {
        return scoreDetailService.QueryScoreDetailByCondition(page , limit ,queryScoreDetail , session);
    }
}
